<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="../global.js"></script>
    <style>
        .box {
            margin: 0 auto;
            position: relative;
            background: url(flash_sale.png);
            width: 702px;
            height: 378px;
        }

        .box div {
            float: left;
            width: 50px;
            height: 50px;
            border: 1px solid #ccc;
            margin-left: 5px;
            line-height: 50px;
            text-align: center;
            color: red;
            position: relative;
            top: 260px;
            left: 305px;
        }

    </style>
</head>
<body>
<div class="box">
    <div id="d"></div>        <!-- 剩余的天数 -->
    <div id="h"></div>        <!-- 剩余的小时 -->
    <div id="m"></div>        <!-- 剩余的分钟 -->
    <div id="s"></div>        <!-- 剩余的秒数 -->
</div>
<script>
    var endtime = new Date("2020-7-2");
    var end = endtime.getTime();
    var d = h = m = s = 0;

    var time = setInterval(seckill, 1000);

    function seckill() {
        //获取当前的时间
        var nowdate = new Date();
        //获取时间差单位为秒
        var tttC = parseInt((end - nowdate.getTime()) / 1000);
        if (tttC > 0) {
            //计算剩余天数（除以60*60*24，获取剩余的天数）
            d = parseInt(tttC / (60 * 60 * 24));
            //计算剩余的小时（除以60*60，得到总剩余小时，然后在%24，结果就是最后剩余小时）
            h = parseInt((tttC / (60 * 60)) % 24);
            //计算剩余的分钟（除以60转换为分钟、在%60分钟就得到剩余分钟）
            m = parseInt((tttC / 60) % 60);
            //计算剩余的秒数（直接%60）;
            s = parseInt(tttC % 60);

            //统一设置两位数显示时间
            d = d < 10 ? "0" + d : d;
            h = h < 10 ? "0" + h : h;
            m = m < 10 ? "0" + m : m;
            s = s < 10 ? "0" + s : s;

        }else {
            clearInterval(time);
            d=h=m=s="00";
        }
        document.getElementById("d").innerHTML=d+"天";
        document.getElementById("h").innerHTML=h+"时";
        document.getElementById("m").innerHTML=m+"分";
        document.getElementById("s").innerHTML=s+"秒";
    }

    console.log(endtime.getTime());

    var d=new Date();
   /* console.log(d.toDateString())//Wed Jul 01 2020
    console.log(d.toTimeString());//20:02:30 GMT+0800 (中国标准时间)


    //常用
    console.log(d.toLocaleDateString())//2020/7/1
    console.log(d.toLocaleTimeString());//下午8:03:31
    console.log(d.toLocaleString());//2020/7/1 下午8:03:59
    
    //获取现在的时间
    console.log(d.format("hh:mm:ss"));*/
   
   console.log(nowNumTime());
</script>
</body>
</html>